package org.lsms.servlet;

/**
 * servlet used to process member decision for every page.
 * @author ZhanXueliang
 * 2010.8.30
 */

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lsms.dao.impl.DaoImpl;

public class member_paper_decision extends HttpServlet {

	public void destroy() {
		super.destroy(); 
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			
			String note_to_chair = (request.getParameter("note_to_chair"));
			int recommend = Integer.parseInt(request.getParameter("recommend"));
			int paper_id = Integer.parseInt(request.getParameter("paper_id"));
			int member_id = Integer.parseInt(request.getParameter("member_id"));
			
//			System.out.println(note_to_chair);
//			System.out.println(recommend);
//			System.out.println(paper_id);
//			System.out.println("member id is "+member_id);
			
			DaoImpl impl = new DaoImpl();
			
			if(impl.member_paper_comment(paper_id, note_to_chair, recommend) && 
					impl.update_paper_assign_1_status(1, paper_id, member_id)){
				String member_info = "Decision has been submitted!+\n";
				if(recommend==1){
					member_info +="You recommend this paper to LSMS.Thank you.";
				}else{
					member_info +="You don't recommend this paper to LSMS.Thank you.";
				}
				response.sendRedirect("member/member_show_info.jsp?member_info="+member_info);
			}else{
				String member_info = "Decision submit failed!Please try again later.";
				response.sendRedirect("member/member_show_info.jsp/member_info="+member_info);
			}
	}

	public void init() throws ServletException {
		
	}

}
